import threading, sqlite3
from .module.timerType import IntervalModule
from .processor import trigger

conn = sqlite3.connect("file.db", check_same_thread=False)

def get_timer_module():
    type = IntervalModule().get_path()
    # 查询
    cur = conn.cursor()
    cur.execute(
        "select id from node where type = ?",
        (type,),
    )
    rows = cur.fetchall()
    for row in rows:
        trigger(row[0])

def repeat():
    get_timer_module()
    threading.Timer(1, repeat, ()).start()

repeat()
